package com.voute.Presenter.Impl;

import com.voute.Model.Bean.BaseBean;
import com.voute.Model.Bean.PersonalFeedBean;
import com.voute.Model.IPersonalFeedModel;
import com.voute.Model.Impl.PersonalFeedModelImpl;
import com.voute.Presenter.IPersonalFeedPresenter;
import com.voute.Utils.CommonSubscriber;
import com.voute.Utils.TransformUtils;
import com.voute.View.IView.IPersonalFeedView;

/**
 * 个人中心中我都收藏我的参与我的创建等共同的presenter
 * Created by liucxu on 2017/1/20.
 */

public class PersonalFeedPresenterImpl implements IPersonalFeedPresenter {
    private IPersonalFeedView feed_view;
    private IPersonalFeedModel model;

    public PersonalFeedPresenterImpl(IPersonalFeedView view) {
        feed_view = view;
        model = new PersonalFeedModelImpl();
    }

    @Override
    public void getPersonalFeed(String type, String anchor,String userId) {
        feed_view.showLoading();
        model.getPersonalFeed(type, anchor,userId).compose(TransformUtils.<PersonalFeedBean>defaultSchedulers()).subscribe(new CommonSubscriber<PersonalFeedBean>() {
            @Override
            public void onSuccess(PersonalFeedBean response) {
                feed_view.hideLoading();
                feed_view.showPersonalFeeds(response);
            }

            @Override
            public void onFailure(BaseBean response) {
                feed_view.hideLoading();
                feed_view.showError(response.getMsg());
            }
        });
    }
}
